package com.cc.Services;

import com.cc.entity.News;
import com.cc.mapper.NewsMapper;


import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NewsServicesImpl implements  INewsService{
    @Autowired
    private NewsMapper newsMapper;
    @Override
    public List<News> listByPage(Integer form, Integer pageSize) {
        Integer page=(form-1)*pageSize;
        return newsMapper.findByPage(page,pageSize);//newsMapper配置文件中定义的只有findByPage方法，用的newsMapper的地方都要用findByPage，
    }

    @Override
    public int deleteByid(Integer id) {
        return newsMapper.delete(id);
    }

   public  int updateById(News news){
        return  newsMapper.updateByPrimaryKey(news);
   }

    @Override
    public int save(News news) {
        return newsMapper.save(news);
    }

    public  News selectByCondition(int enId) {
        return newsMapper.selectByCondition(enId);
    }

    @Override
    public int total() {
        return newsMapper.total();
    }
}
